<template>
	<Container class="manage-edit">
		<div class="container-header title title-center" slot="header">申请商品
      <Button size="large" class="fl btn-back" icon="ios-arrow-back" @click="$router.back()">返回</Button>
    </div>
    <SortEditItem @toSecond='toEdit'/>
    <div class="container-footer bg-white" slot="footer">
        <Button size="large"  type="primary" :disabled='!disabled' @click="nextStep">下一步</Button>       
    </div>
	</Container>
</template>

<script>
import SortEditItem from "./edit/SortEditItem"
export default {
  data() {
    return {
			toEditData: {}, // 带到编辑商品页的数据
      disabled: false,
      isEdit: false
    }
  },
  components: {
    SortEditItem
  },
  mounted() {
    this.isEdit = this.$route.query.from === 'edit' ? true : false   
  },
  methods: {
    toEdit(param) {
      this.disabled = !!param.endId
      this.toEditData = param
    },
    nextStep() {
      this.$router.push({
        name: "product/apply/edit",
        query: {
          toEditData: JSON.stringify(this.toEditData),
          from: this.isEdit ? 'edit' : 'add'
        }
      });
    }
  }
};
</script>

